<template>
  <div>
    <div class="background">
      <img src="../assets/backinm4.jpg" width="100%" height="100%" alt="" />
    </div>
    <div class="front">
      <el-card class="box-card">
        <div slot="header" class="clearfix">
          <i class="el-icon-s-data" />
          <b class="Logo">****</b>
        </div>

        <el-form :model="ruleForm" :rules="rules" ref="ruleForm">
          <el-form-item label="" prop="PersonnelUserName">
            <el-input
              v-model="ruleForm.PersonnelUserName"
              placeholder="Admin"
            ></el-input>
          </el-form-item>
          <el-form-item label="" prop="PersonneIPassword">
            <el-input
              v-model="ruleForm.PersonneIPassword"
              show-password
              placeholder="password"
            ></el-input>
          </el-form-item>
          <el-form-item>
            <el-button type="success" @click="submitForm('ruleForm')"
              >立即登录</el-button
            >
            <el-button type="info" @click="ddd=true"
              >无法登陆</el-button
            >
          </el-form-item>
        </el-form>
        <span v-show="ddd" style="color: white">tip:请联系管理员处理</span>
      </el-card>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      ddd:false,
      ruleForm: {},
      rules: {
        PersonnelUserName: [
          { required: true, message: "请输入用户名", trigger: "blur" },
        ],
        PersonneIPassword: [
          { required: true, message: "请输入密码", trigger: "blur" },
        ],
      },
    };
  },
  created() {},
  computed: {},
  methods: {
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.$http.get(`Login/Logoin?PersonnelUserName=${this.ruleForm.PersonnelUserName}&PersonneIPassword=${this.ruleForm.PersonneIPassword}`).then(res=>{
              if(res.data.Code==200){
                //传递token
                  localStorage.setItem("token",res.headers.token)
                  //传递用户ID
                  sessionStorage.setItem("UserID",res.data.Data.PersonnelId)
                  //传递用户名
                  sessionStorage.setItem("UserName",res.data.Data.PersonnelName)
                  //传递头像
                  sessionStorage.setItem("HeadPortrait",res.data.Data.HeadPortrait)
                  //跳转页面
                  this.$router.push("/Home")
                  console.log(res.data.Data.PersonnelId,res.data.Data.PersonnelName,res.data.Data.HeadPortrait)
              }else{
                  this.$message.error('登录失败请检查用户名或密码');
              }
          })
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
  },
};
</script>
<style scoped>
.background {
  width: 100%;
  height: 100%; /**宽高100%是为了图片铺满屏幕 */
  z-index: -1;
  position: absolute;
}
.front {
  width: 100%;
  height: 100%; /**宽高100%是为了图片铺满屏幕 */
  z-index: 1;
  position: absolute;
}
.clearfix {
  text-align: center;
  font-family: 幼圆;
  font-size: 35px;
  color: rgba(50, 50, 50, 0.8);
}
.el-icon-s-data {
  margin-left: 10px;
  line-height: 55px;
  font-size: 30px;
}
.box-card {
  margin-left: calc(calc(100vw - 400px) / 2);
  width: 400px;
  background-color: rgba(200, 200, 200, 0.6);
  border-color: rgba(200, 200, 200, 0.5);
  border-radius: 10px;
  margin-top: 15%;
  border-radius: 20px
}
.el-button {
  width: 175px;
}
.el-card__header {
  padding: 10px 15px;
}
</style>
<style>
.el-card__header {
  padding: 5px;
}
body {
  margin: 0;
  padding: 0;
  
}
</style>
